# coding=utf-8
import requests, os, time

headers = {
	'Host': 'p.urlpic.club',
	'Connection': 'keep-alive',
	'Cache-Control': 'max-age=0',
	'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
	#  'X-Requested-With': 'XMLHttpRequest http://p.urlpic.club/imghost/upload/image/20170712/71206416472.jpg',
	'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.89 Safari/537.36',
	# 'DNT': '1',
	## 'Accept-Encoding': 'gzip, deflate',
	'Accept-Language': 'zh-CN,zh;q=0.8,ja;q=0.6',
	'Referer': 'http://1024.stv919.net/pw/thread.php?fid=14'
}


f=open('/dhms/f/spidera.log','r')

conn=requests.session()

for line in f.readlines():
	print line.strip()
	try:
		rsq = conn.get(line.strip(),headers=headers,timeout=5)
		print rsq.status_code
		print rsq.headers
		print rsq.cookies
	except requests.HTTPError,e:
		print e
		pass

	name = str(long(int(round(time.time() * 1000))))
	p = open("/dhms/f/" + name + ".jpg", 'wb')
	p.write(rsq.content)
	p.close()
conn.close()



# url='http://p.urlpic.club/imghost/upload/image/20170712/71206415587.jpg'
#
# rsq=requests.get(url)
# print rsq.status_code
#
#
# f=open("c://WORKSPACE//logs//b.jpg",'w+')
# f.write(rsq.content)
# f.close()
